/*
 * Copyright (C) 2012 Jakub Narloch (jmnarloch@gmail.com), All Rights Reserved.
 */

package org.soa.security.web.controller;

import org.soa.security.model.dto.ServiceConfigurationDTO;
import org.soa.security.model.entities.ServiceType;
import org.soa.security.service.KeyStoreService;
import org.soa.security.service.LookupService;
import org.soa.security.service.SoaServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>Lookup entities controller.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author Jakub Narloch (jmnarloch@gmail.com)
 * @version 1.0
 */
@Controller
public class LookupController {

    /**
     * <p>Instance of {@link LookupService} used for retrieving the lookup entities.</p>
     *
     * <p>Null by default.</p>
     *
     * <p>Autowired by IOC container.</p>
     */
    @Autowired
    private LookupService lookupService;

    /**
     * <p>Creates new instance of {@link LookupController} class.</p>
     */
    public LookupController() {
        // empty constructor
    }

    /**
     * <p>Handles request for all service types.</p>
     *
     * @return list of service types
     */
    @RequestMapping(value = "/Lookup/ServiceType", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public List<ServiceType> getServiceTypes() throws SoaServiceException {

        return lookupService.getServiceTypes();
    }
}
